﻿// Copyright (c) egmkang wang. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace XServer.GrainInterfaces
{
    using System;
    using System.Threading.Tasks;
    using System.Collections.Generic;
    using Orleans;
    using Orleans.Concurrency;
    using XServer.Message;

    /// <summary>
    /// 数据规模较小的排行榜, 规模最好的1000个人以下
    /// Grain的PrimaryKey格式是: ServerID_RankType_MaxCount
    /// 都是按照V1来排序
    /// </summary>
    public interface IRankGrain : IGrainWithStringKey
    {
        /// <summary>
        /// 更新玩家的排行信息
        /// </summary>
        /// <param name="item">详细数据</param>
        /// <returns>老的排名和新的排名</returns>
        Task<KeyValuePair<int, int>> UpdatePlayerInfo(RankItemInfo item);

        /// <summary>
        /// 获取玩家的排名
        /// </summary>
        /// <param name="playerID">玩家ID</param>
        /// <returns>返回排名, 不在排行榜返回-1</returns>
        Task<int> GetRank(long playerID);

        /// <summary>
        /// 删除某个玩家的排名
        /// </summary>
        /// <param name="playerID">玩家ID</param>
        /// <returns>TaskDone</returns>
        Task Remove(long playerID);

        /// <summary>
        /// 获取排行榜的所有排行数据
        /// </summary>
        /// <returns>排行数据</returns>
        Task<List<RankItemInfo>> GetAllData();

        /// <summary>
        /// 清除排行榜数据
        /// </summary>
        /// <returns>TaskDone</returns>
        Task Clear();

        /// <summary>
        /// 获取排行榜内玩家的数量
        /// </summary>
        /// <returns>玩家的数量</returns>
        Task<int> GetPlayerCount();
    }
}
